﻿// Check all checkbox in ListView
function checkAll(isChecked, cssSignature, buttonCSS) {
    
    $("." + cssSignature + " > input").each(function() {
        this.checked = isChecked;
    });

    $("." + buttonCSS).each(function() {
        this.disabled = !isChecked;
    });
    
}

// Correct All checkboxes depends on State
function correctCheckboxAll(isChecked, cssSignature, cssSignatureOfCheckboxAll, buttonCSS) {
    var isTheSame = true;
    var hasChecked = false;
    $("." + cssSignature + " > input").each(function() {
        if (this.checked != isChecked) {
            isTheSame = false;
        }
        if (this.checked) {
            hasChecked = true;       
        }
    });

    var value = false;
    if (isTheSame) {
        value = isChecked;
    }

    $("." + cssSignatureOfCheckboxAll + " > input").each(function() {
        this.checked = value;
    });

    $("." + buttonCSS).each(function() {        
        this.disabled = !hasChecked;
    });
}

function hasChecked(cssSignature) {
    checked = false;
    $("." + cssSignature + " > input").each(function() {
        if (this.checked) {
            return true;
        }
    });

    return checked;
}

// Enable or Disable Control depends on checkbox status
function ChangeStatus(checkboxID, buttonID) {
    if (document.getElementById(checkboxID).checked) {
        document.getElementById(buttonID).disabled = false;
    }
    else {
        document.getElementById(buttonID).disabled = true;
    }
}

// Go to url
function Go(url) {
    // Redirect to UserRegistration.aspx
    window.location = url;
}
